<html>
 <head>
  <meta charset="UTF-8">
 </head>
 <body>
  <h1 data-lake-id="LD60D" id="LD60D"><span data-lake-id="u0be109f5" id="u0be109f5">典型回答</span></h1>
  <p data-lake-id="u036578bf" id="u036578bf"><strong><span data-lake-id="ub744f2a0" id="ub744f2a0">​</span></strong><br></p>
  <ol list="u1c704dcc">
   <li fid="u6b752a7a" data-lake-id="2b0d8c244ac173ab59945fc4803675d0_li_26" id="2b0d8c244ac173ab59945fc4803675d0_li_26"><strong><span data-lake-id="u9f2a59c9" id="u9f2a59c9">URL解析</span></strong><span data-lake-id="ueb0b3cb0" id="ueb0b3cb0">，对URL自动编码，然后检查长度，之后根据url查看浏览器是否缓存了该页面</span></li>
   <li fid="u6b752a7a" data-lake-id="c0e830a7432b6533fcf01413475379d0_li_27" id="c0e830a7432b6533fcf01413475379d0_li_27"><strong><span data-lake-id="uf6b9e1e6" id="uf6b9e1e6">DNS</span></strong><span data-lake-id="u51b55d1d" id="u51b55d1d">查询，依次通过浏览器缓存，OS hosts缓存，路由器缓存，ISP缓存和根域名服务器去查询对应的ip</span></li>
   <li fid="u6b752a7a" data-lake-id="ca96433ed9cd9812b902647865128c08_li_28" id="ca96433ed9cd9812b902647865128c08_li_28"><span data-lake-id="u8057e4d4" id="u8057e4d4">浏览器将请求封装为</span><strong><span data-lake-id="u93de0018" id="u93de0018">HTTP</span></strong><span data-lake-id="u681672af" id="u681672af">报文，在client和server建立连接之前，会进行</span><strong><span data-lake-id="u14c87d05" id="u14c87d05">TCP三次握手</span></strong></li>
   <li fid="u6b752a7a" data-lake-id="72d80ae474be2a2d495ac6f92c2131f1_li_29" id="72d80ae474be2a2d495ac6f92c2131f1_li_29"><span data-lake-id="uf7234a78" id="uf7234a78">之后将报文从外到里封装为 以太网首部+ip首部+tcp首部+http首部经过</span><strong><span data-lake-id="u4e76f604" id="u4e76f604">网关和路由器</span></strong><span data-lake-id="u1de3960a" id="u1de3960a">发送给server</span></li>
   <li fid="u6b752a7a" data-lake-id="ec57f5ad1f0925c25b8d17c921649353_li_30" id="ec57f5ad1f0925c25b8d17c921649353_li_30"><span data-lake-id="u2218ca8f" id="u2218ca8f">对于淘宝来说，请求会先到</span><strong><span data-lake-id="u094b978f" id="u094b978f">nginx服务器</span></strong><span data-lake-id="u35c544fd" id="u35c544fd">上，然后nginx采用默认的轮询算法进行</span><strong><span data-lake-id="ue15fd657" id="ue15fd657">负载均衡</span></strong><span data-lake-id="ub5fac6b8" id="ub5fac6b8">，携带原来browser的ip把报文发送给</span><strong><span data-lake-id="u9f11bf23" id="u9f11bf23">Servlet容器</span></strong></li>
   <li fid="u6b752a7a" data-lake-id="74bf0911d175423b0d42471fcf155d07_li_31" id="74bf0911d175423b0d42471fcf155d07_li_31"><span data-lake-id="u32104dcb" id="u32104dcb">Servlet容器接收到请求之后会解析请求行，请求体，请求头，然后交给</span><strong><span data-lake-id="ufd043608" id="ufd043608">MVC</span></strong><span data-lake-id="uc3a2dfec" id="uc3a2dfec">处理</span></li>
   <li fid="u6b752a7a" data-lake-id="21906ea258053913988a15bbf5fb33a9_li_32" id="21906ea258053913988a15bbf5fb33a9_li_32"><span data-lake-id="ufba58ebf" id="ufba58ebf">DispatcherServlet接收到请求后，通过请求路径返回相应的</span><strong><span data-lake-id="u08ce927f" id="u08ce927f">拦截器和Controller；</span></strong></li>
   <li fid="u6b752a7a" data-lake-id="ua352fa35" id="ua352fa35"><span data-lake-id="u8333f8dc" id="u8333f8dc">在Controller中会进行业务逻辑的执行，可能会调用下层的Service以及持久层进行数据的CRUD。</span></li>
   <li fid="u6b752a7a" data-lake-id="ua3f72bde" id="ua3f72bde"><span data-lake-id="u022b07b2" id="u022b07b2">对Controller进行处理并返回ModelAndView；然后在通过ViewResolve对ModelAndView进行处理，返回View视图；最后一步是进行渲染View，产生response</span></li>
   <li fid="u6b752a7a" data-lake-id="6b788fb02c616c0a65012a73d7bb1a1d_li_33" id="6b788fb02c616c0a65012a73d7bb1a1d_li_33"><span data-lake-id="ua95001ce" id="ua95001ce">浏览器接收</span><strong><span data-lake-id="uf70aa72b" id="uf70aa72b">response</span></strong><span data-lake-id="u7379bf0d" id="u7379bf0d">，HTTP响应报文的头部包含了状态码（Status-Code），并进行</span><strong><span data-lake-id="ue54854f3" id="ue54854f3">缓存和解码</span></strong></li>
   <li fid="u6b752a7a" data-lake-id="76882ffa4dbedc5c9b4bdae5362e409a_li_34" id="76882ffa4dbedc5c9b4bdae5362e409a_li_34"><span data-lake-id="u93448265" id="u93448265">浏览器</span><strong><span data-lake-id="u23f864fe" id="u23f864fe">渲染页面</span></strong></li>
  </ol>
 </body>
</html>